import 'package:flutter/material.dart';
import 'package:flutter_jd/ui/widgets/indicator/underline_indicator.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class TabBarCustom extends StatelessWidget {
  final List tabs;
  final EdgeInsets indicatorInsets;
  final TabController tabController;

  TabBarCustom({
    Key? key,
    required this.tabs,
    this.indicatorInsets = const EdgeInsets.fromLTRB(0, 0, 0, 0),
    required this.tabController,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Theme(
      data: ThemeData(
        splashColor: Colors.transparent,
        highlightColor: Colors.transparent,
      ),
      child: Container(
        width: double.infinity,
        decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.only(
            bottomLeft: Radius.circular(10.r),
            bottomRight: Radius.circular(10.r),
          ),
        ),
        child: TabBar(
          controller: tabController,
          indicator: UnderlineTabIndicatorCustom(
            indicatorWidth: 25.w,
            borderSide: BorderSide(
              color: Colors.red,
              width: 2.7.w,
            ),
            shape: StrokeCap.round,
            insets: EdgeInsets.fromLTRB(0, 0, 0, 10.h),
          ),
          indicatorSize: TabBarIndicatorSize.label,
          unselectedLabelColor: Color(0xFF666666),
          labelColor: Color(0xFF222222),
          labelStyle: TextStyle(fontWeight: FontWeight.bold),
          unselectedLabelStyle: TextStyle(
            fontSize: 14.sp,
            fontWeight: FontWeight.w500,
          ),
          tabs: tabs
              .map(
                (text) => Container(child: Tab(text: text)),
              )
              .toList(),
        ),
      ),
    );
  }
}
